package org.jeecg.enums.meter;

/**
 * 发票开票状态
 *  0待开票 1开票成功 2 开票中 3 开票失败
 */
public enum MeterInvoiceStatusEnum {
    INVOICE_STATUS_WAIT(0, "待开票"),
    INVOICE_STATUS_SUCCESS(1, "开票成功"),
    INVOICE_STATUS_CONDUCT(2, "开票中"),
    INVOICE_STATUS_ERROR(3, "开票失败"),
    ;

    private Integer code;
    private String desc;

    MeterInvoiceStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static String getDesc(Integer value) {
        if (value == null) return "";
        MeterInvoiceStatusEnum[] enums = values();
        for (MeterInvoiceStatusEnum typeEnum : enums) {
            if (value.intValue()  == typeEnum.getCode().intValue()) {
                return typeEnum.desc;
            }
        }
        return "";
    }

    public static Integer getValue(String desc) {
        MeterInvoiceStatusEnum[] enums = values();
        for (MeterInvoiceStatusEnum typeEnum : enums) {
            if (typeEnum.getDesc().equals(desc)) {
                return typeEnum.code;
            }
        }
        return null;
    }

}
